package com.pkk.penguin.test.elasticsearch.repository;

import com.pkk.penguin.test.elasticsearch.entity.Article;
import java.util.List;
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

/**
 * @description: 存储库实体操作
 * @author: peikunkun
 * @create: 2019-10-14 09:34
 **/
public interface ArticleRepository extends ElasticsearchRepository<Article, Long> {


  /**
   * @Description: 查询文章信息
   * @Param: [id]
   * @return: com.pkk.penguin.test.elasticsearch.entity.Article
   * @Author: peikunkun
   * @Date: 2019/10/18 0018 下午 3:18
   */
  Article queryArticleInfoById(Long id);


  /**
   * @Title: queryArticleByTitleAndContent<br>
   * @Description: <查询文章依据标题或内容><br>
   * @author peikunkun<br>
   * @date 2017年2019/10/18 0018 下午 3:24<br>
   * @URL:[]
   * @version V1.0<br>
   */
  @Query(value = "{\"bool\":{\"must\":[{\"match\":{\"title\":\"?0\"}},{\"match\":{\"content\":\"?1\"}}]}}")
  List<Article> queryArticleByTitleContentAnnotation(String title, String content);


  /**
   * @Description: 查询
   * @Param: [title, content]
   * @return: com.pkk.penguin.test.elasticsearch.entity.Article
   * @Author: peikunkun
   * @Date: 2019/10/18 0018 下午 3:48
   */
  //List<Article> queryArticleByBaseTitleContent(String title, String content);

}
